package com.example.jk.common;

import lombok.Data;


@Data
public class Result {
    private int code;
    private String msg;
    private Long count;
    private Object data;

    public static Result success(Object data) {
        Result result = new Result();
        result.code = 200;
        result.msg = "操作成功";
        result.data = data;
        return result;
    }

    public static Result success() {
        Result result = new Result();
        result.code = 200;
        result.msg = "操作成功";
        return result;
    }

    public static Result success(String msg) {
        Result result = new Result();
        result.code = 200;
        result.msg = msg;
        return result;
    }

    public static Result success(String msg, Object data) {
        Result result = new Result();
        result.code = 200;
        result.msg = msg;
        result.data = data;
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.code = 400;
        result.msg = msg;
        result.data = "";
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.code = 400;
        result.msg = "操作失败";
        result.count = 0l;
        result.data = "";
        return result;
    }
}
